import axios from 'axios'
import config from '../config'

export function saveKeyShip (shipId,mmsi, terminalType, userId) {
  let url = config.SERVER_URL + window.apiPath + '/key-ships'
  var param = {}
  param.userId = userId
  param.terminalType = terminalType
  param.mmsi=mmsi
  param.shipId=shipId;
  //var paramShip = {}
  //paramShip.id = shipId
  //param.ship = paramShip
  return axios.post(url, {...param, responseType: 'json'})
    .then(resp => resp.data)
}

export function deleteById (id) {
  let url = config.SERVER_URL + window.apiPath + '/key-ships/' + id
  return axios.delete(url).then(resp => resp.data)
}

export function search (userId) {
  let url = config.SERVER_URL + window.apiPath + '/key-ships-s?query=userId==' + userId
  return axios.get(url).then(resp => resp.data)
}
